<template>
  <van-swipe
    class="my-swipe"
    indicator-color="#f50"
    :height="375"
    :autoplay="2000"
    :duration="1000"
    @change="onChange"
  >
    <van-swipe-item v-for="item in slider_image" :key="item" class="item">
      <img :src="item" alt="" />
    </van-swipe-item>

    <template #indicator>
      <div class="custom-indicator">{{ current + 1 }}/{{slider_image.length}}</div>
    </template>
  </van-swipe>
</template>

<script>
export default {
  data() {
    return {
      current: 0,
    };
  },
  props: {
    slider_image: {
      type: Array,
    },
  },
  methods: {
    onChange(index) {
      this.current = index;
    },
  },
};
</script>

<style lang="scss" scoped>
.item {
  width: 100%;
  img {
    width: 100%;
    height: 100%;
  }
}

.custom-indicator {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 5px;
  font-size: 12px;
  background: #fff;
}
</style>

